<template>
	<view class="apply">
		<view class="item" v-for="item in applyList" :key="item.id" @click="toPage(item)">
			<view class="title">
				<text>{{ item.jobName }}</text>
				<view class="tpis" v-show="item.status === 1"></view>
			</view>
			<view class="time wrap">
				<text class="yzb label-icon yzb-shijian"></text>
				<text>{{ timeFormat(item.date) }}</text>
				<text class="line"></text>
				<text>{{ item.startTime }} 至 {{ item.endTime }}</text>
			</view>
			<view class="address wrap">
				<text class="yzb label-icon yzb-location"></text>
				<text>{{ item.address }}</text>
			</view>
			<view class="user-info">
				<view class="avatar"><image :src="item.avatar" mode="aspectFill"></image></view>
				<text class="name">{{ item.nickName }}</text>
			</view>
		</view>
	</view>
</template>

<script>
import { getApplyList } from '@/apis/apply/apply.js';

export default {
	data() {
		return {
			applyList: []
		};
	},
	onShow() {
		this.initData();
	},
	methods: {
		async initData() {
			const userId = this.$store.state.userInfo.id;
			const res = await getApplyList(userId);
			this.applyList = res.data;
		},
		// 格式化时间
		timeFormat(value) {
			return uni.$uv.timeFormat(value);
		},
		toPage(info) {
			
			uni.navigateTo({ url: '/pages/student/apply-detail?info=' + encodeURIComponent(JSON.stringify(info)) });
		}
	}
};
</script>

<style lang="scss" scoped>
.line {
	width: 4rpx;
	height: 20rpx;
	margin: 0 15rpx;
	background-color: #ccc;
}

.apply {
	padding: 20rpx;
	.item {
		padding: 20rpx 30rpx;
		margin-bottom: 20rpx;
		border-radius: 16rpx;
		background-color: #fff;
		.title {
			display: flex;
			justify-content: space-between;
			& > text {
				font-size: 36rpx;
				font-weight: bold;
				color: $main-color;
			}
			.tpis {
				width: 20rpx;
				height: 20rpx;
				border-radius: 20rpx;
				background-color: #e45656;
			}
		}
		.wrap {
			display: flex;
			align-items: center;
			margin: 10rpx 0;
			font-size: 30rpx;
			color: #606266;
			.label-icon {
				margin-right: 20rpx;
			}
		}
		.user-info {
			display: flex;
			align-items: center;
			margin-top: 20rpx;
			.avatar image {
				width: 80rpx;
				height: 80rpx;
				border-radius: 100%;
				margin-right: 20rpx;
			}
			.name {
				font-size: 32rpx;
			}
		}
	}
}
</style>
